﻿Imports System.Data
Imports System.Data.SqlClient

Partial Class _Default
    Inherits BasePage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Function GetDataForGrid() As String
        Dim _return As New StringBuilder
        Dim rList As List(Of InventoryItem) = InventoryItem.FetchReorderList()
        Dim _count As Integer = 1
        For Each i As InventoryItem In rList
            '   { PartNumber: "1", Description: "Item 1", Quantity: "1", ReorderPoint: "11" },
            _return.Append("{")
            _return.Append("ID: '" & i.ID.ToString & "', ")
            _return.Append("PartNumber: '" & i.PartNumber & "', ")
            _return.Append("Description: '" & i.Description & "', ")
            _return.Append("Quantity: '" & i.Quantity & "', ")
            _return.Append("ReorderPoint: '" & i.ReorderPoint & "'")
            _return.Append("}")
            If _count <> rList.Count Then
                _return.Append(",")
                _count = _count + 1
            End If
            _return.Append(vbCrLf)
        Next

        Return _return.ToString
    End Function
End Class
